package JsoupTest;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

public class etst {
	public static void main(String[] args) {

		try {
			downloadFile(
					"http://www.supercars.net/gallery/119513/2841/1035597.jpg",
					"C:\\images");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			System.err.println("There was an error");
			Logger.getLogger(DownloadImages.class.getName()).log(Level.SEVERE,
					null, e);
		}

	}

	public static void downloadFile(String src, String target)
			throws IOException {
		src = null;

		// open URL stream
		URL url = new URL(src);
		InputStream in = url.openStream();
		OutputStream out = new BufferedOutputStream(
				new FileOutputStream(target));
		for (int b; (b = in.read()) != -1;) {
			out.write(b);
		}
		in.close();
		out.close();
	}
}
